/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package service;

import graphviewer.GraphViewer;
import java.awt.Color;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.awt.RenderingHints;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionListener;
import javax.swing.JFrame;
import javax.swing.JPanel;

/**
 *
 * @author Sabitov Artem
 * @date 02.10.2013
 */
public class ServiceMouse extends JPanel implements MouseMotionListener {
	private int posX = 0;
	private int posY = 0;
	
	@Override
	protected void paintComponent(Graphics g) {
		super.paintComponent(g);
        Graphics2D g2d = (Graphics2D) g;
        g2d.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
		Font font = new Font("Arial", 1, 10); 
		g2d.setFont(font);
		// смещение по х = 8, по y = 30. учитываем рамку воруг 
		g2d.drawString(/*"debug: " + */"X: " + (posX - 8) + " Y: " + (posY - 30), 4, 8);//4, 726);
		setBounds(0, 720, 80, 10);
	}
	
	public ServiceMouse(JFrame objFrame) {
		setBackground(Color.RED);
		setOpaque(Service.getStateDebugComponent());
		setBounds(0, GraphViewer.FRAME_HEIGHT - 48, 80, 10);
		initMouseListener(objFrame);
	}
	
	private void initMouseListener(JFrame objFrame) {
		objFrame.addMouseMotionListener(this);
	}
	
	@Override
	public void mouseDragged(MouseEvent me) {
		posX = me.getX();
		posY = me.getY();
		repaint();
	}

	@Override
	public void mouseMoved(MouseEvent me) {
		posX = me.getX();
		posY = me.getY();
		repaint();
	}
}